<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<base href="<%=basePath%>">
    <title>东方直播后台系统 登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />    
    <link href="assets/login/bootstrap.min.css" rel="stylesheet" />
    <link href="assets/login/font-awesome.css" rel="stylesheet" />
    <link href="assets/login/login.css" rel="stylesheet" /> 
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="assets/js/html5shiv.js"></script>
		<script src="assets/js/respond.min.js"></script>
		<![endif]-->
  	</head>
<body>
	
<div id="login-container">
	<div id="login-header">
		<h3><center>东方直播后台系统</center></h3>
	</div> <!-- /login-header -->
	<div id="login-content" class="clearfix">
	<fieldset>
		<div class="control-group">
			<div class="controls">
				<input type="text" id="loginname" placeholder="帐号" />
			</div>
		</div>
		<div class="control-group">
			<div class="controls">
				<input type="password" id="password" placeholder="密码" />
			</div>
		</div>
		<div class="control-group">
			<input type="text" id="code" placeholder="验证码" style="width:20%;"/>
			<img id="codeImg" alt="点击更换" title="点击更换" style="height:22px;"  /> 
			
			<div class="pull-right">
				<input type="checkbox" id="saveid" onclick="savePaw();" style="width:20px;" />记住密码&nbsp;&nbsp;
				<button type="button" onclick="severCheck();" class="btn btn-default btn-large">登录</button>
			</div>
		</div>
	</fieldset>
	</div> <!-- /login-content -->
	<div id="login-extra">
		<p>© 2016-2017 众标软件  版权所有</p>
	</div> <!-- /login-extra -->
</div> <!-- /login-wrapper -->

<center><p style="font-size: 12px;color: #888;">为了提高您的用户体验，推荐您使用谷歌Chrome浏览器、Firefox、Safari、IE9及以上版本浏览器</p>
<p style="font-size: 12px;color: #888;">如果您使用360浏览器，请参考<a href="https://www.baidu.com/s?wd=360%E6%B5%8F%E8%A7%88%E5%99%A8%E9%80%89%E6%8B%A9iE9%E5%86%85%E6%A0%B8&rsv_spt=1&rsv_iqid=0xe83c5c7400008582&issp=1&f=3&rsv_bp=1&rsv_idx=2&ie=utf-8&rqlang=cn&tn=baiduhome_pg&rsv_enter=0&oq=%26lt%3B60%E6%B5%8F%E8%A7%88%E5%99%A8%E9%80%89%E6%8B%A9%26gt%3B9%E5%86%85%E6%A0%B8I&rsv_t=a48csAghN5v8%2BzqJeS5BCIA3vOSv0UE5KP2phXdFl11GSolFGmTbx%2B2p%2FBrzmQLoDh2q&sug=360%E6%B5%8F%E8%A7%88%E5%99%A8%E9%80%89%E6%8B%A9%E5%86%85%E6%A0%B8&inputT=4911&rsv_pq=d08bb70200007a9e&rsv_sug3=22&rsv_sug2=0&prefixsug=%3C60%E6%B5%8F%E8%A7%88%E5%99%A8%E9%80%89%E6%8B%A9i%3E9%E5%86%85%E6%A0%B8&rsp=2&rsv_sug4=5664" target="_blank">设置</a>IE内核为IE9及以上</p>
</center>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" src="assets/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="assets/js/jquery.tips.js"></script>
<script type="text/javascript" src="assets/js/jquery.cookie.js"></script>
<script type="text/javascript">
	jQuery(function() {
		var loginname = $.cookie('loginname');
		var password = $.cookie('password');
		var type = $.cookie('type');
		if (typeof(loginname) != "undefined"
				&& typeof(password) != "undefined") {
			$("#loginname").val(loginname);
			$("#password").val(password);
			$("#saveid").attr("checked", true);
			$("#code").focus();
			if(type==1){
				 $("input[name='type']:eq(1)").attr("checked","checked");
			}
			
		}
	});
	$(document).ready(function() {
		changeCode();
		$("#codeImg").bind("click", changeCode);
	});
	function changeCode() {
		var time = new Date();
		$("#codeImg").attr("src", "code.do?t=" + time.getTime());
	}
	//服务器校验
	function severCheck(){
		if(check()){
			var loginname = $("#loginname").val();
			var password = $("#password").val();
			var code = loginname+",zt,"+password+",zt,"+$("#code").val();
			$.ajax({
				type: "POST",
				url: 'admin/login.do',
		    	data: {KEYDATA:code},
				dataType:'json',
				cache: false,
				success: function(data){
					if("success" == data.result){
						saveCookie();
						window.location.href="admin/index.do";
					}else if("usererror" == data.result){
						$("#loginname").tips({
							side : 1,
							msg : "用户名或密码有误",
							bg : '#FF5080',
							time : 5
						});
						$("#loginname").focus();
					}  else if("codeerror" == data.result){
						$("#code").tips({
							side : 1,
							msg : "验证码输入有误",
							bg : '#FF5080',
							time : 5
						});
						$("#code").focus(); 
					} else if("time"== data.result){
						$("#loginname").tips({
							side : 1,
							msg : "此版本试用期已到！",
							bg : '#FF5080',
							time : 5
						});
						$("#loginname").focus();
					}else{
						$("#loginname").tips({
							side : 1,
							msg : "缺少参数",
							bg : '#FF5080',
							time : 5
						});
						$("#loginname").focus();
					}
				}
			});
		}
	}
	//客户端校验
	function check() {
		if ($("#loginname").val() == "") {
			$("#loginname").tips({
				side : 2,
				msg : '帐号不得为空',
				bg : '#AE81FF',
				time : 3
			});

			$("#loginname").focus();
			return false;
		} else {
			$("#loginname").val(jQuery.trim($('#loginname').val()));
		}

			if ($("#password").val() == "") {

				$("#password").tips({
					side : 2,
					msg : '密码不得为空',
					bg : '#AE81FF',
					time : 3
				});

				$("#password").focus();
				return false;
			}
			if ($("#code").val() == "") {

				$("#code").tips({
					side : 1,
					msg : '验证码不得为空',
					bg : '#AE81FF',
					time : 3
				});

				$("#code").focus();
				return false;
			}  

			$("#loginbox").tips({
				side : 1,
				msg : '正在登录 , 请稍后 ...',
				bg : '#68B500',
				time : 10
			});
			return true;
		}

		function savePaw() {
			if (!$("input[type='checkbox']").is(':checked')) {
				$.cookie('loginname', '', {
					expires : -1
				});
				$.cookie('password', '', {
					expires : -1
				});
				$("#loginname").val('');
				$("#password").val('');
			}
		}
		function saveCookie() {
			if ($("input[type='checkbox']").is(':checked')) {
				$.cookie('loginname', $("#loginname").val(), {
					expires : 7
				});
				$.cookie('password', $("#password").val(), {
				expires : 7
			});
			$.cookie('type', $("input[name='type']:checked").val(), {
				expires : 7
			});
		}
	}
	//TOCMAT重启之后 点击左侧列表跳转登录首页 
	if (window != top) {
		top.location.href = location.href;
	}
</script>

  </body>
</html>